const { Axios } = require('axios');
const fs = require('fs');
const solt = require('../service/solt');
/**
 * 加载配置文件setting.json
 */
global.setting = null;

function load() {
    try {
        global.setting = JSON.parse(fs.readFileSync('./setting.json','utf-8'));
        console.log("全局setting 加载成功");
    } catch(e) {
        throw new Error("全局setting 加载失败")
    }
}

load();

guard_man = function () {       // ai 留空
    this.temper = 36;    // 红温警戒

    this.see = function(mes) {  // 大爷瞅一眼
        return true;
    }
}

var fa = new guard_man();

guard = function(mes,resp) {
    if(!mes)    return;
    
    console.log("guard程序进入");
    // 过滤程序
    // console.log(mes);

    solt.queFunc(mes,resp);

    // 看门大爷
    if( !fa.see(mes) ) {
        return;
    }
    // 分发
    console.log(resp);
    console.log("大爷认为行");

    // 服务

    return resp;
    
}

module.exports = {
    guard: guard
}